<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字符串去重</title>
</head>

<body>

</body>
<script>
    let str = "aabccd";

    let strToArr = str.split('');

    let newStr = strToArr.reduce(function (pre, cur) {
        return pre.indexOf(cur) == -1 ? pre.concat(cur) : pre;
    }, []).join('')
    console.log(newStr);
</script>

</html>